<template>
 <div class="cmt">
     <h2>发表评论</h2>
     <hr>
     <textarea placeholder="请输入要BB的内容（做多吐槽120字）" maxlength="120" v-model="value"></textarea>
     <mt-button type="primary" size="large" @click="postComment">发表评论</mt-button>
    <div class="cmt-list">
        <div class="cmt-item" v-for="(item,i) of commits" :key="item.content">
            <div class="cmt-title">
                第{{i+1}}楼&nbsp;&nbsp;用户：{{item.name}}&nbsp;&nbsp;发表时间：{{item.date|dateFormat}}
            </div>
            <div class="cmt-body">
                {{item.content}}
            </div>
        </div>
    </div>
        <mt-button type="danger" size="large" plain>加载更多</mt-button>

 </div>
</template>

<script>
import { Toast } from "mint-ui";
 export default {
   data () {
     return {
         value:"",
         commits:[{
             name:"wzw",
             date:Date.now(),
             content:"666"
         }]
     }
   },
   components: {

   },
   methods:{
       postComment(){
           if(this.value.trim().length===0){
               return Toast("评论内容不能为空！")
           }
           var cmt={
               name:"wzw",
               data:Date.now(),
               content:this.value.trim()
           }
           this.commits.unshift(cmt)
           this.value=""
       }
   }
 }
</script>
<style lang="scss" scoped>
.cmt{
    h2{
        font-size: 18px;
    }
    textarea{
        font-size: 1px;
        height: 80px;
        margin: 0
    }
    .cmt-list{
        margin: 5px 0;
        .cmt-item{
            font-size: 13px;
             .cmt-title{
                 line-height: 30px;
                 background: chartreuse
             }
               .cmt-body{
                   line-height: 35px;
                   text-indent: 2em;
               }
        }
    }
}
</style>

